﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using FinosLibrary.Client;
using FinosLibrary;
using System.IO;
using System.Xml;
namespace BattleShipOnline {
    public class Config {
        public static Config instance;
        public static void Init() {
            try {
                WebClient wc = new WebClient();
                wc.OpenReadCompleted += (object sender, OpenReadCompletedEventArgs e) => {
                    try {
                        instance = e.Result.FromXML<Config>();
                    } catch (Exception) {
                        instance = XmlReader.Create("config.xml").FromXML<Config>();
                    }
                };
                wc.OpenReadAsync(new Uri("config.xml".AbsolutePath(),UriKind.Relative));
            } catch (Exception e) {
                MessageBox.Show(e.Message);
            }
        }

        public string server { get; set; }
        public string connection { get; set; }
    }
}
